<?php

// +----------------------------------------------------------------------
// | H1CMS © OpenSource CMS
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2016 http://www.h1cms.com All rights reserved.
// | Copyright (c) 2014-2016 嘉兴领格信息技术有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Allen <allen@lg4.cn>
// +----------------------------------------------------------------------

namespace h1cms\model;

use h1cms\system\Model;

/**
 * Description of CategoryLanguage
 *
 * @author Allen <allen@lg4.cn>
 */
class CategoryLanguage extends Model {

    public $table = 'category_language';
    public $primaryKey = 'category_id';
    public $languageKey = 'lang_id';

    /**
     * 
     * @param int $category_id
     * @param int $lang_id
     * @return \h1cms\model\CategoryLanguage
     */
    public static function get($category_id, $lang_id = 0) {
        return static::getDb()
                        ->query("select * from {category_language} where category_id=:category_id AND lang_id=:lang_id", [
                            'category_id' => $category_id,
                            'lang_id' => $lang_id
                        ])
                        ->fetchObject(get_called_class());
    }

}
